package api

import (
	"net/http"

	"gitee.com/h2ob/base"
	"gitee.com/h2ob/facada"
	"gitee.com/h2ob/infra"
	"github.com/gin-gonic/gin"
)

func forward(c *gin.Context) {

}

func callback(c *gin.Context) {
	rsp := facada.H2oAiRsp{}
	if err := c.BindJSON(&rsp); err != nil {
		base.GLogger.Infoln("Can not find args:%s", err)
		c.String(http.StatusBadRequest, "Can not find args")
		return
	}
	c.String(http.StatusOK, "OK")
}

func genTravel(c *gin.Context) {
	req := facada.H2oAiTravelReq{}
	if err := c.BindJSON(&req); err != nil {
		base.GLogger.Infoln("Can not find args:%s", err)
		c.String(http.StatusBadRequest, "Can not find args")
		return
	}
	id, err := infra.BeginItineraryGen()
	if err != nil {
		c.String(http.StatusInternalServerError, "Call failed")
		return
	}
	rsp, err := infra.DoGenItinerary(id, &req)
	if err != nil {
		c.String(http.StatusInternalServerError, "Call failed")
		return
	}
	hRsp := facada.H2oRsp{TID: req.TID, Code: http.StatusOK, Msg: "OK", Data: rsp}
	c.JSON(http.StatusOK, &hRsp)
}
